package com.yulian.util;
 
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.Log4JLoggerFactory;
import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.redis.client.Redis;
import io.vertx.redis.client.RedisConnection; 
/**
 * 连接Redis的工具类
 * @author 余大勇
 *
 */
public class RedisConnectionUtil {
	final InternalLogger logger = Log4JLoggerFactory.getInstance(RedisConnectionUtil.class);
 
 	/**
 	 * 创建Redis连接 RedisConnection
 	 * @param redis
 	 * @return
 	 */
	public static Future<RedisConnection> createRedisClient(Redis redis) {
		Promise<RedisConnection> promise = Promise.promise();   
		redis
        .connect() //连接 Redis
        .onSuccess(conn -> { 
          // allow further processing
        	promise.complete(conn); 
        }).onFailure(t -> {
        	promise.fail(t); 
        }); 
	    return promise.future();
	}  
}
